package com.qf.service.impl;

import com.qf.entity.Answers;
import com.qf.mapper.AnswersMapper;
import com.qf.service.AnswersService;
import com.qf.service.QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Lenovo
 * @version 1.0
 * @date 2021/10/4
 */
@Service
public class AnswersServiceImpl implements AnswersService {

    @Autowired
    private QuestionsService questionsService;

    @Autowired
    private AnswersMapper answersMapper;

    @Override
    @Transactional
    public void insertAnsers(Answers answers) {
        answersMapper.insertSelective(answers);
        questionsService.updateCountAddOneByQid(answers.getQid());
        questionsService.updateLastModifedTime(answers);
    }
}
